package com.ruoyi.project.app.controller;

import com.ruoyi.project.app.util.XResult;
import com.ruoyi.project.beautyflower.advertisement.domain.Advertisement;
import com.ruoyi.project.beautyflower.advertisement.service.IAdvertisementService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/app/advertisement")
@Api(tags = "广告模块 ")
public class AppAdvertisementController {
    @Autowired
    private IAdvertisementService advertisementService;
    /**
     * 根据广告类型查询广告数据
     * @param type
     * @return
     */
    @PostMapping("queryDisburseResult")
    @ApiOperation(notes = "queryDisburseResult", value = "根据广告类型查询广告数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "广告类型", required = true, paramType = "query", dataType = "int")
    })
    public Object queryDisburseResult(@RequestParam @ApiIgnore Integer type, @ApiIgnore HttpServletRequest request)  {
        Advertisement advertisement=new Advertisement();
        advertisement.setType(type);
        advertisement.setLine(1);
        return new XResult("查询成功", advertisementService.selectAdvertisementByType(advertisement));
    }
}
